home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / amac44d.zip / SR.BAT < prev    next >
DOS Batch File  |  1992-06-22  |  4KB  |  96 lines

  1. : SR.BAT Search/Replace, Can Remove Text From Files                    6/1/92
  2. :
  3. :1) SYNTAX:                           sr.bat %1 %2 %3
  4. :                                  ┌──────────┘  │  └───────────┐
  5. :             (Mode)              %1            %2             %3
  6. :                            Search Text     Replace Text   File Name/List
  7. :         ----------------   -------------   ------------   --------------
  8. :      a) Query                   [ ]           [ ]            [ ]
  9. :      b) Partial Query      Search Text        [ ]            [ ]
  10. :      c) Partial Query      Search Text        [ ]         File Name/List
  11. :      d) Command line       Search Text     Replace Text      [ ]
  12. :      e) All command line   Search Text     Replace Text   File Name/List
  13. :
  14. :         where:    %1  - Search Text
  15. :                   %2  - Replace Text
  16. :                   %3  - File Name or [@File_List], default SRCH-FG.LST
  17. :                   [ ] - entered at query prompt
  18. :2) Requires FGREP.COM, INPUT.COM and sr2.mac                              *|
  19. :3) Uses File_List %FileList% if no File Name is specified during input.
  20. :   Specify File Name list as [@FileList] to use an alternate File_List,
  21. :   or specify File Name, wild cards OK.
  22. :4) FGREP options──CANNOT──be changed from default "fl"
  23. :5) Set environment variable OPT=off to bypass File Name query prompt
  24. :   and use %FileList%. Set  OPT=    to *not* bypass File Name query prompt.
  25. :
  26. :
  27. :
  28. :*******************************************************************************
  29. :*                                                                             *
  30. :* Environment Variable        Action                                          *
  31. :* --------------------------- ----------------------------------------------- *
  32. :* set opt=                    does not bypass File Name query prompt          *
  33. :* set opt=off                 bypasses File Name query prompt                 *
  34. :* set filelist=               uses sm.lst for testing this batch file         *
  35. :* set filelist=srch-fg.lst    searches with standard file list srch-fg.lst    *
  36. :* set filelist=c:\srch-fg.lst searches with standard file list c:\srch-fg.lst *
  37. :* set srmac=                  macro files are located in current directory    *
  38. :* set srmac=c:\               macro files are located in c:\ directory        *
  39. :*                                                                             *
  40. :*******************************************************************************
  41. :
  42. @echo off
  43. cls
  44. echo SR.BAT,  June 1, 1992
  45. set S~~=%1
  46. set R~~=%2
  47. set file=%3
  48. if     "%filelist%" == "" set filelist=sm.lst
  49. if not "%1" == ""    if not "%2" == "" goto 2b
  50. if not "%1" == ""    goto 1a
  51. if     "%1" == ""    echo Search Text: [Enter terminates batch file]
  52. INPUT.COM Search Text=/b
  53. if errorlevel=1 goto 6a
  54. set S~~=%ans%
  55. goto 2a
  56. :1a
  57. echo Search Text=%S~~%
  58. :2a
  59. set ans=
  60. if "%2" == "" echo Replace Text: [Enter removes search text]
  61. INPUT.COM Replace Text=/b
  62. :   if errorlevel=1 goto 6a, removed, June 1, 1992                         *|
  63. set R~~=%ans%
  64. :2b
  65. set ans=
  66. if not "%opt%" == "" goto 2c
  67. if not    "%3" == "" goto 2c
  68. echo File Name(s): [Enter=%FileList%]  [File Name(s)]  [@FileList]
  69. INPUT.COM file list=/b
  70. set file=%ans%
  71. :2c
  72. if "%file%" == "@" set file=@%filelist%
  73. if "%file%" == ""  set file=@%filelist%
  74. :4a
  75. cls
  76. echo SR.BAT,  June 1, 1992
  77. echo Search Text   = %S~~%
  78. echo Replace Text  = %R~~%
  79. echo File Name     = %file%
  80. break on
  81. FGREP.COM -fl /%S~~%/  %file% >c:\$.ql
  82. break off
  83. set >c:\$
  84. copy c:\$.ql c:\!
  85. Q.EXE        c:\!    /E%srmac%SR.MAC /L%srmac%SR.MAC
  86. goto 7a
  87. :6a
  88. echo.
  89. echo Search/Replace──INCOMPLETE──
  90. goto 8a
  91. :7a
  92. echo.
  93. echo Search/Replace──Complete──
  94. :8a
  95. echo.
  96.